package com.db;

import com.template.tool.StringUtil.StringUtil;

public class ColumnInfoBean implements java.io.Serializable {

	private String name;
	private String typeName;
	private String className;
	private String displaySize;
	private String precision;
	private String scale;
	private String displayName;
	private boolean allowNull;
	private String defaultValue = null;
	
	private boolean display = true;
	
	private String noPresitionTypeName;
	
	//表单中字段名
	private String fieldName;

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String getDisplaySize() {
		return displaySize;
	}

	public void setDisplaySize(String displaySize) {
		this.displaySize = displaySize;
	}

	public String getPrecision() {
		return precision;
	}

	public void setPrecision(String precision) {
		this.precision = precision;
	}

	public String getScale() {
		return scale;
	}

	public void setScale(String scale) {
		this.scale = scale;
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public boolean isAllowNull() {
		return allowNull;
	}

	public void setAllowNull(boolean allowNull) {
		this.allowNull = allowNull;
	}

	public boolean isDisplay() {
		return display;
	}

	public void setDisplay(boolean display) {
		this.display = display;
	}
	
	public String getJavaClassNameBySQLType() {
    	String className = "String";
        if(this.typeName.equalsIgnoreCase("NVARCHAR")) {                	
        }else if(this.typeName.equalsIgnoreCase("NVARCHAR2")) {
        	
        }else if(this.typeName.equalsIgnoreCase("VARCHAR")) {
        	
        }else if(this.typeName.equalsIgnoreCase("VARCHAR2")) {
        	
        }else if(this.typeName.equalsIgnoreCase("CHAR")) {
        	
        }else if(this.typeName.equalsIgnoreCase("NUMBER")) {
        	//数字
        	className = "Integer";
        }else if(this.typeName.equalsIgnoreCase("DATE")) {
        	//时间
        	className = "Date";
        }
        
    	return className;
    }
	
	
	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}
	
	public String getDefineJavaComment(String name) {
    	String className = getJavaClassNameBySQLType();
    	String comment = "";
        if(className.equalsIgnoreCase("String")) { 
        	comment = StringType.getDefaultComment(name);
        }else if(className.equalsIgnoreCase("Integer")) {
        	comment = IntegerType.getDefaultComment(name);
        }else if(className.equalsIgnoreCase("Date")) {
        	comment = DateType.getDefaultComment(name);
        }
        
    	return comment;
    }
	
	

	public String getJavaComment(String name, String value) {
    	String className = getJavaClassNameBySQLType();
    	String comment = "";
        if(className.equalsIgnoreCase("String")) { 
        	comment = StringType.getComment(name, value);
        }else if(className.equalsIgnoreCase("Integer")) {
        	comment = IntegerType.getComment(name, value);
        }else if(className.equalsIgnoreCase("Date")) {
        	comment = DateType.getComment(name, value);
        }
        
    	return comment;
    }
	
	//name> mike
	public String getJavaSetComment(String name, String value) {
    	String className = getJavaClassNameBySQLType();    
    	String comment = "";
        if(className.equalsIgnoreCase("String")) { 
        	comment = StringType.getSetComment(name, value);
        }else if(className.equalsIgnoreCase("Integer")) {
        	comment = IntegerType.getSetComment(name, value);
        }else if(className.equalsIgnoreCase("Date")) {
        	comment = DateType.getSetComment(name, value);
        }
        
    	return comment;
    }
	
	//value> orgName
	public String getJavaSetValueComment(String name, String value) {
    	String className = getJavaClassNameBySQLType();
    	String comment = "";
        if(className.equalsIgnoreCase("String")) { 
        	comment = StringType.getSetFieldValueComment(name, value);
        }else if(className.equalsIgnoreCase("Integer")) {
        	comment = IntegerType.getSetFieldValueComment(name, value);
        }else if(className.equalsIgnoreCase("Date")) {
        	comment = DateType.getSetComment(name, value);
        }
        
    	return comment;
    }
	
	/**
	 * java
	 * @return
	 */
	public String getPropertyName() {
		StringUtil sutil = new StringUtil();
		return sutil.getPropertyName(name);
	}
	
	public String getPropertyClassName() {
		StringUtil sutil = new StringUtil();
		return sutil.getFirstUpperName(sutil.getPropertyName(name));
	}
	
	public String getTypesName() {
		
    	String comment = "";
        if(typeName.equalsIgnoreCase("CHAR")) {         	
        	comment = "Types.CHAR";
        }else if(typeName.equalsIgnoreCase("VARCHAR")) {            
        	comment = "Types.VARCHAR";
        }else if(typeName.equalsIgnoreCase("NVARCHAR")) {        	
        	comment = "Types.NVARCHAR";
        }else if(typeName.equalsIgnoreCase("VARCHAR2")) {            
        	comment = "Types.VARCHAR";
        }else if(typeName.equalsIgnoreCase("NVARCHAR2")) {            
        	comment = "Types.NVARCHAR";
        }else if(typeName.equalsIgnoreCase("NUMBER")) {            
        	comment = "Types.NUMERIC";
        }else if(typeName.equalsIgnoreCase("DATE")) {           
        	comment = "Types.DATE";
        }
        return comment;
	}

	public String getNoPresitionTypeName() {		
		return noPresitionTypeName;
	}

	public void setNoPresitionTypeName(String noPresitionTypeName) {
		this.noPresitionTypeName = noPresitionTypeName;
	}
	
	
	
}
